home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
conhlp.arc
/
CONHELP.C
next >
Wrap
Text File
|
1988-11-23
|
8KB
|
258 lines
#include <nvt.h>
#include <ndt.h>
#include <string.h>
#include "conhelp.h"
extern int Keyword, MyHeaderSegment;
int machineType, handle, serverNumber, currentDrive, index, scrIndex;
int ImStillUp, ccode, loginError, mainProcessID;
char inputChar, serverName[48], buffer[14], readBuffer[MAX_BUFFER_SIZE+1];
char *localPath;
main()
{
ImStillUp = 1;
ccode = loginError = 0;
mainProcessID = GetProcessID();
if ( ( machineType = VGetFileServerName( serverName ) ) == FILESERVER )
{
ccode = VAPAttachToFileServer( serverName, &serverNumber );
switch ( ccode )
{
case 0:
SetPreferredConnectionID( serverNumber );
break;
case 1:
VAPMapFileServerNameToNumber( serverName, &serverNumber );
SetPreferredConnectionID( serverNumber );
break;
default:
VPrintString( -1, -1, "Unable to attach to Server ", -1 );
VPrintString( -1, -1, serverName, -1 );
VPrintString( -1, -1, ".\n\r", -1 );
VPrintString( -1, -1, "Console Help VAP not loaded.\n\r", -1 );
ImStillUp = 0;
break;
}
if ( ImStillUp )
{
if ( ccode = LoginToFileServer( "GUEST", 1, NULL ) )
{
loginError = 1;
switch ( ccode )
{
case 0xFC:
VPrintString( -1, -1, "User GUEST must be defined on Server ", -1 );
VPrintString( -1, -1, serverName, -1 );
VPrintString( -1, -1, " to use the Console Help VAP.\n\r", -1 );
ImStillUp = 0;
break;
case 0xDA:
VPrintString( -1, -1, "Unauthorized login time for user GUEST on server ", -1 );
VPrintString( -1, -1, serverName, -1 );
VPrintString( -1, -1, ".\n\r", -1 );
VPrintString( -1, -1, "Modify user GUEST's allowed login times with the SYSCON utility.\n\r", -1 );
VPrintString( -1, -1, "(Note: You must be a SUPERVISOR or supervisor equivalent to modify login times)\n\r", -1 );
ImStillUp = 0;
break;
case 0xDB:
VPrintString( -1, -1, "Unauthorized login station for user GUEST on server ", -1 );
VPrintString( -1, -1, serverName, -1 );
VPrintString( -1, -1, ".\n\r", -1 );
VPrintString( -1, -1, "Modify user GUEST's allowed login stations with the SYSCON utility.\n\r", -1 );
VPrintString( -1, -1, "(Note: You must be a SUPERVISOR or supervisor equivalent to modify login stations)\n\r", -1 );
ImStillUp = 0;
break;
default:
VPrintString( -1, -1, "Error ", -1 );
itoa( ccode, buffer, 10 );
VPrintString( -1, -1, buffer, -1 );
VPrintString( -1, -1, "h occurred while attempting to login to Server ", -1 );
VPrintString( -1, -1, serverName, -1 );
VPrintString( -1, -1, ".\n\r", -1 );
ImStillUp = 0;
break;
}
}
}
if ( ImStillUp )
{
if ( ccode = VOpen( "SYS:PUBLIC/CONHELP.DAT", 0x40, &handle ) )
{
switch ( ccode )
{
case 0xFF:
if ( !loginError )
VPrintString( -1, -1, "CONHELP.DAT file not found in SYS:PUBLIC.\n\r", -1 );
ImStillUp = 0;
break;
case 0x93:
case 0x94:
case 0x82:
VPrintString( -1, -1, "Not enough privileges to open CONHELP.DAT.\n\r", -1 );
VPrintString( -1, -1, "Check the EFFECTIVE rights of user GUEST in SYS:PUBLIC.\n\r", -1 );
VPrintString( -1, -1, "User GUEST must have at least R(ead) O(pen) S(earch) rights.\n\r", -1 );
ImStillUp = 0;
break;
default:
VPrintString( -1, -1, "Error occurred opening SYS:PUBLIC/CONHELP.DAT: ", -1 );
itoa( ccode, buffer, 10 );
VPrintString( -1, -1, buffer, -1 );
VPrintString( -1, -1, "h \n\r", -1 );
ImStillUp = 0;
break;
}
}
}
}
if ( machineType == BRIDGE )
{
VSetPassThroughMode( 1 );
if ( ( currentDrive = VGetCurrentDisk() ) != 0xFF )
{
currentDrive += 65; /* convert it to an ascii drive letter value */
buffer[0] = currentDrive;
buffer[1] = 0x00;
localPath = strcat( buffer, ":\\CONHELP.DAT" );
}
else
{
VPrintString( -1, -1, "Error occurred during GetCurrentDisk.\n\r", -1 );
ImStillUp = 0;
}
if ( ccode = VOpen( localPath, 0x40, &handle ) )
{
switch ( ccode )
{
case 0x02:
VPrintString( -1, -1, localPath, -1 );
VPrintString( -1, -1, "-file not found.\n\r", -1 );
break;
case 0x03:
VPrintString( -1, -1, localPath, -1 );
VPrintString( -1, -1, "-path not found.\n\r", -1 );
break;
default:
VPrintString( -1, -1, "Error occurred opening ", -1 );
VPrintString( -1, -1, localPath, -1 );
VPrintString( -1, -1, ": ", -1 );
itoa( ccode, buffer, 10 );
VPrintString( -1, -1, buffer, -1 );
VPrintString( -1, -1, "h \n\r", -1 );
break;
}
}
VSetPassThroughMode( 0 );
}
VInitializationComplete();
while ( 1 )
{
VSleepProcess();
if ( ( index >= 0 ) && ( index <= 7 ) )
{
if ( MenuList[index].menuPtr != NULL )
{
ClearScreen();
PrintArray( MenuList[index].menuPtr, MenuList[index].menuLength );
VSleepProcess();
scrIndex = toupper( inputChar ) - 'A';
if ( ( scrIndex >= 0 && scrIndex <= ( MAX_MENU_ITEMS-1 ) )
&& ( MenuList[index].Screen[scrIndex].screenPtr != NULL ) )
{
ClearScreen();
PrintArray( MenuList[index].Screen[scrIndex].screenPtr,
MenuList[index].Screen[scrIndex].screenLength );
}
}
}
else
if ( index == 8 )
{
ClearScreen();
PrintArray( MAINHELPOFF, MAINHELPLEN );
}
else
VPrintString( -1, -1, "No help for specified command.\r\n", -1 );
}
}
ConsoleHandler()
{
if ( ImStillUp )
{
ccode = GetScreenMode();
switch ( ccode )
{
case 0:
SetScreenMode( MyHeaderSegment );
break;
case 0xFFFF:
SetScreenMode( MyHeaderSegment );
break;
default:
break;
}
if ( ( ccode != MyHeaderSegment ) && ( ccode > 0 ) )
{
ConsoleDisplay( "Help is disabled until another VAP releases screen control." );
return( 0 );
}
else
{
inputChar = '\0';
index = Keyword / 2;
WakeUpProcess( mainProcessID );
if ( ( index >=0 ) && ( index <=7 ) )
{
VInString( MenuList[index].menuLength, 2, ">", &inputChar, 1 );
VPrintString( -1, -1, &inputChar, 1 );
VPrintString( -1, -1, "\n\r", -1 );
WakeUpProcess( mainProcessID );
}
}
}
return( 0 );
}
DownHandler()
{
ImStillUp = 0;
ConsoleDisplay( "Console Help VAP is down." );
return( 0 );
}
PrintArray( p, numRecords )
long p;
unsigned numRecords;
{
int i;
long newPointer;
unsigned bytesRead=0;
if ( numRecords <= MAX_RECORDS )
{
memset( readBuffer, '\0', MAX_BUFFER_SIZE );
if ( machineType == BRIDGE )
VSetPassThroughMode( 1 );
newPointer = VSeek( handle, p, BEG_FILE );
if ( ( bytesRead = VRead( handle, readBuffer, ( RECORD_SIZE*numRecords ) ) ) == 0 )
{
VPrintString( -1, -1, "Error reading CONHELP.DAT.\n\r", -1 );
VPrintString( -1, -1, "Number of bytes successfully read: ", -1 );
itoa( bytesRead, buffer, 10 );
VPrintString( -1, -1, buffer, -1 );
VPrintString( -1, -1, "\n\r", -1);
ImStillUp = 0;
}
if ( machineType == BRIDGE )
VSetPassThroughMode( 0 );
if ( ImStillUp )
{
readBuffer[bytesRead] = '\0';
for ( i = 0;i < numRecords;i++ )
VPrintString( -1, -1, &readBuffer[ ( i*RECORD_SIZE ) ], RECORD_SIZE );
}
}
}